package scripts;

import java.io.File;
import java.util.List;

import launcher.Script;

import common.LocalUtil;

public class GeneraPaquete extends Script{

	public GeneraPaquete(String projectFilePath, String impDirPath){
		super("Copiado", null, null);
		setParameter("ProjectFilePath", projectFilePath);
		setParameter("ImpDirPath", impDirPath);
	}
	
	public void exec() {
		String impDirPath = (String)getParameter("ImpDirPath",String.class);
		LocalUtil.deleteFileRecursive(new File(impDirPath + "Upstream/"));
		LocalUtil.deleteFileRecursive(new File(impDirPath + "Buyer/"));

		List<String> fileList = LocalUtil.readFileList((String)getParameter("ProjectFilePath",String.class));
		if (fileList != null) {
			for(String path : fileList){
				LocalUtil.copyfile(LocalUtil.getLocalPath(path.substring(path.indexOf("\\") + 1), path.startsWith("Upstream")), impDirPath + path);
			}
		}
	}
}
